﻿using IMES.Common.Domain.GoldIngotModel;
using IMES.Common.Dtos;
using IMES.Common.Infrastructure;
using MediatR;

namespace GoldIngot.API.Application.Commands.SigningWorkCommand
{
    public class SigningWorkFillHandler : IRequestHandler<SigningWorkFillCommand, ResultT<SigningWork>>
    {
        private readonly IBaseRepositorys<SigningWork> signingRep;
        private readonly ILogger<SigningWorkFillHandler> logger;

        public SigningWorkFillHandler(IBaseRepositorys<SigningWork> signingRep, ILogger<SigningWorkFillHandler> logger)
        {
            this.signingRep = signingRep;
            this.logger = logger;
        }

        public async Task<ResultT<SigningWork>> Handle(SigningWorkFillCommand request, CancellationToken cancellationToken)
        {
            var quest = new ResultT<SigningWork>();
            quest.Item = signingRep.GetAll().FirstOrDefault(x => x.SigningId == request.SigningId);
            return quest;
        }
    }
}
